package com.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import struts.action.Action;
import struts.form.ActionForm;

import com.vo.User;

public class LoginAction implements Action {

	public String execute(HttpServletRequest request, ActionForm form, Map<String, String> actionForward) {
		User user = (User) form;
		String result = "";
		if ("admin".equals(user.getUserName())) {
			if ("admin".equals(user.getPassword())) {
				request.setAttribute("msg", "登录成功");
				result = actionForward.get("success");
			} else {
				request.setAttribute("msg", "密码错误");
				result = actionForward.get("error");
			}
		} else {
			request.setAttribute("msg", "用户名不存在");
			result = actionForward.get("error");
		}

		return result;
	}

}
